package com.ruoyi.system.interfacechannel.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ruoyi.system.V2.inter.mapper.SalePartnerMapper;
import com.ruoyi.system.interfacechannel.domain.InterfaceChannel;
import com.ruoyi.system.interfacechannel.mapper.InterfaceChannelMapper;
import com.ruoyi.system.interfacechannel.service.IInterfaceChannelService;
import com.ruoyi.system.model.domain.SalePartner;
import com.ruoyi.system.model.domain.SelectPush;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Objects;

/**
 * 接口渠道表(interface_channel)表服务实现类
 *
 * @author zyy
 * @date 2024-01-10 10:18:26
 */
@Service("interfaceChannelService")
public class InterfaceChannelServiceImpl extends ServiceImpl<InterfaceChannelMapper, InterfaceChannel> implements IInterfaceChannelService {

    @Autowired
    SalePartnerMapper salePartnerMapper;

    @Override
    public InterfaceChannel getBySalePartnerId(SelectPush selectPush) {
        SalePartner salePartner = salePartnerMapper.selectSalePartnerById(Long.valueOf(selectPush.getConfig()));
        if (Objects.nonNull(salePartner)) {
            return getById(salePartner.getInterfaceUserId());
        }
        return null;
    }
}

